package com.qf.czh.comprehensive.controller;

import com.qf.czh.comprehensive.model.User;
import com.qf.czh.comprehensive.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    UserService userService;
    @GetMapping("/user")
    @ResponseBody
    public List<User> getUsers(){
        List<User> users = userService.getUsers();
        return users;
    }

    @GetMapping("/user/th")
    public String getAllusers(Model model){
        List<User> users = userService.getUsers();
        System.out.println(users);
        model.addAttribute("users", users);
        return "users";
    }
}
